//--------------------------------------------------------------
//
// Qizhi Zhang 
// ezhung@gmail.com
// http://www.moorwind.com
//
//--------------------------------------------------------------
package reader.model.vo
{
	import __AS3__.vec.Vector;
	
	public class BlogLabelVO extends SelectAbleVO
	{
		public var name:String;
		public var labelid:int = -1;
		public var fieldsArray:Vector.<int> = new Vector.<int>; // BlogSource.blogSourceId
				
		public function get fields():String
		{
			return this.fieldsArray.join(",");
		}
		
		public function get label():String
		{
			return name.length > 12 ? name.substr(0, 12) + "..." : name;
		}
		
		public function toString():String
		{
			return "[BlogLabel] labelid=" + labelid + " name=" + name + "\n";
		}
		
		public static function getBlogLabelById(labelid:int, blogLabelArray:Vector.<BlogLabelVO>):BlogLabelVO
		{
			var r:BlogLabelVO;
			for each(var bl:BlogLabelVO in blogLabelArray)
			{
				if(bl.labelid == labelid)
					r = bl;
			}
			return r;
		}
		
		//----------------------------------------------------------------------------
		//
		// Convert Vector to Array
		//
		//----------------------------------------------------------------------------
		
		public static function VectorToArray(v:Vector.<BlogLabelVO>):Array/* of BlogLabelVO */
		{
			var a:Array = [];
			for each(var i:BlogLabelVO in v)
			{
				a.push(i);
			}
			return a;
		}

	}
}